using System.Data;
using PersistenceObject.Framework.Expressions;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System;
using PersistenceObject.Framework.Interface;

namespace PersistenceObject.Framework
{
    public delegate T GetInfoFromReader<T>(IDataReader reader);
    
    public interface IQuery : ISqlAccess
    {
        IExpression Expressions { get; set; }
        FieldAdapter[] GroupBy { get; set; }
        FieldAdapter[] OrderBy { get; set; }
        FieldAdapter[] Selects { get; set; }
        IDbCommand DbCommand { get; }
        int Top { get; set; }
        string CreateSql { get;}

        IList<T> List<T>() where T : class;
        IList<T> List<T>(IDbCommand com) where T : class;
        IList<T> List<T>(String sql) where T : class;
        IList<T> List<T>(GetInfoFromReader<T> getInfoFromReader) where T : class;
        IList<T> List<T>(String commandText, CommandType commandType) where T : class;

        IList<Combined<T1, T2>> List<T1, T2>()
            where T1 : class
            where T2 : class;
        IList<Combined<T1, T2>> List<T1, T2>(IDbCommand com)
            where T1 : class
            where T2 : class;
        IList<Combined<T1, T2>> List<T1, T2>(String sql)
            where T1 : class
            where T2 : class;
        IList<Combined<T1, T2>> List<T1, T2>(String commandText, CommandType commandType)
            where T1 : class
            where T2 : class;

        IList<Combined<T1, T2, T3>> List<T1, T2, T3>()
            where T1 : class
            where T2 : class
            where T3 : class;
        IList<Combined<T1, T2, T3>> List<T1, T2, T3>(IDbCommand com)
            where T1 : class
            where T2 : class
            where T3 : class;
        IList<Combined<T1, T2, T3>> List<T1, T2, T3>(String sql)
            where T1 : class
            where T2 : class
            where T3 : class;
        IList<Combined<T1, T2, T3>> List<T1, T2, T3>(String commandText, CommandType commandType)
            where T1 : class
            where T2 : class
            where T3 : class;
        
        IList List();
        T Get<T>() where T : class;
        T Get<T>(GetInfoFromReader<T> getInfoFromReader) where T : class;
        T Get<T>(String commandText, CommandType commandType) where T : class;
        T Get<T>(String sql) where T : class;

        Combined<T1, T2> Get<T1, T2>()
            where T1 : class
            where T2 : class;
        Combined<T1, T2> Get<T1, T2>(String commandText, CommandType commandType)
            where T1 : class
            where T2 : class;
        Combined<T1, T2> Get<T1, T2>(String sql)
            where T1 : class
            where T2 : class;


        Combined<T1, T2, T3> Get<T1, T2, T3>()
            where T1 : class
            where T2 : class
            where T3 : class;
        Combined<T1, T2, T3> Get<T1, T2, T3>(String commandText, CommandType commandType)
            where T1 : class
            where T2 : class
            where T3 : class;
        Combined<T1, T2, T3> Get<T1, T2, T3>(String sql)
            where T1 : class
            where T2 : class
            where T3 : class;

        DataSet GetDataSet();
        IDataReader ExecuteReader();
        IDataReader ExecuteReader(CommandBehavior commandBehavior);
        IDataReader ExecuteReader(string sp, Collection<FieldValue> parameters);
        object ExecuteScalar(string sp, Collection<FieldValue> parameters);
        object ExecuteScalar();

        IPager CreatePager(Int32 size);

        IPager CreatePager();

        //Int32 Skip { get; set; }

    }
}

